<cfif not IsDefined("email") AND not IsDefined("UserNme") AND not IsDefined("thepassword")>
	<cfset session.message ="There was a problem with the information you submitted.">
	<cflocation url="/ecada/registration/register.cfm" addToken="no">
</cfif>

<cfif #UserNme# eq "">
<cfset session.message ="Cannot have a blank username!">
<cflocation url="/ecada/registration/register.cfm" addToken="no">
</cfif>

<cfif #thepassword# eq "">
<cfset session.message ="Cannot have a blank password.">
<cflocation url="/ecada/registration/register.cfm" addToken="no">
</cfif>
<cfif IsDefined("session.captcha") AND IsDefined("session.captcharesult")>
	<cfif session.captcha neq session.captcharesult>
		<cfset session.message="Incorrect captcha!">
		<cflocation url="/ecada/registration/register.cfm" addToken="no">
	</cfif>
<cfelse>
	<cfset session.message="There was a problem with your captcha!">
	<cflocation url="/ecada/registration/register.cfm" addToken="no">
</cfif>

<cfquery name="details" datasource="exp">
    SELECT *
    FROM user
    WHERE  username=<cfqueryparam cfsqltype="cf_sql_varchar" value="#UserNme#">
    OR email=<cfqueryparam cfsqltype="cf_sql_varchar" value="#email#">
</cfquery>

<cfif #details.RecordCount# gt 0>
<cfset session.message = "Account for that email address already exists">
	<cflocation url="/ecada/registration/register.cfm" addToken="no">
</cfif>

<cfquery name="details" datasource="exp">
    INSERT INTO user (email, password, name, username)
    VALUES( <cfqueryparam cfsqltype="cf_sql_varchar" value='#email#'>,
 				<cfqueryparam cfsqltype="cf_sql_varchar"value='#thepassword#'>,
 				<cfqueryparam cfsqltype="cf_sql_varchar" value='#thename#'>,
 				<cfqueryparam cfsqltype="cf_sql_varchar" value='#UserNme#'>)
</cfquery>

<cfset session.message = "Account Created. Please log in">
<cflocation url="/ecada/registration/register.cfm" addToken="no">


